<template>
  <div id="app" :class="classes">
    <!--    <PageNav v-if="isPageNav" :label="meta.title" :sub-label="meta.subTitle" />-->
    <div class="pages">
      <transition :name="transitionName">
        <navigation>
          <router-view />
        </navigation>
      </transition>
    </div>
  </div>
</template>

<script>
import { GlobalVar, Device } from 'utils';

export default {
  data() {
    return {
      transitionName: '',
    };
  },
  head() {
    const { meta } = this;
    return {
      title:
        `${meta.title || ''}${meta.subTitle ? ` - ${meta.subTitle}` : ''}` ||
        GlobalVar.DocTitle,
    };
  },
  computed: {
    meta() {
      return this.$route.meta;
    },
    classes() {
      return [
        {
          'device-pc': Device.desktop,
        },
      ];
    },
    isPageNav() {
      return Device.desktop;
    },
    isFromShare() {
      return this.$utils.hasOwn(this.$route.query, 'fromShare');
    },
    showQuickNavigation() {
      const {
        isFromShare,
        $route: { name },
      } = this;
      return isFromShare && name && name !== 'index';
    },
  },
  created() {
    this.$navigation.on('forward', (to, from) => {
      if (from.route.path === '/') {
        this.transitionName = '';
      } else {
        this.transitionName = 'left';
      }
    });
    this.$navigation.on('replace', () => {
      this.transitionName = '';
    });

    this.$navigation.on('back', () => {
      this.transitionName = 'right';
    });

    if (Device.desktop) {
      document.body.style.overflowX = 'auto';
      document.body.style.backgroundColor = '#252e39';
    }

    this.$wxSDK.hideAllNonBaseMenuItem();
  },
  mounted() {},
};
</script>

<style lang="scss">
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  width: 100%;
  height: 100%;
  overflow: hidden;

  &.device-pc {
    width: 1000px;
    margin: 0 auto;
  }
}
</style>
